import React, {Component} from 'react';
import qs from 'querystringify'

class Detail extends Component {

    state={
        messageList:[
            {id:'01',content:'A'},
            {id:'02',content:'B'},
            {id:'03',content:'C'}

        ]
    }

    render() {
        console.log(this.props)

        // params接收参数
        const{id,message}=this.props.match.params
        // query接收参数
        // const res=qs.parse(this.props.location.search)
        // const{id,message}=res
        // state接收参数
        // const{id,message}=this.props.location.state


        const findContent=this.state.messageList.find((item)=>{
            return item.id===id
        })
        return (
            <div>
                <ul>
                    <li>ID:{id}</li>
                    <li>title:{message}</li>
                    <li>content:{findContent.content}</li>
                </ul>
            </div>
        );
    }
}

export default Detail;